<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<title>Codigo Fuente de: Utilidades.pas</title>
<style type="text/css">
body {background-color:black}
span {
	font-family: 'Courier New';
	font-size: 9pt;
	color: #FFFFFF;
}
.sc0 {
}
.sc1 {
	font-style: italic;
	color: #00FF40;
}
.sc2 {
	font-style: italic;
	color: #0080FF;
}
.sc4 {
	color: #FF00FF;
}
.sc7 {
	color: #FFFF00;
}
.sc9 {
	color: #808080;
}
.sc10 {
	color: #FF8040;
}
.sc12 {
}
.sc13 {
}
</style>
</head>
<body>
<div style="float: left; white-space: pre; line-height: 1; background: #000000; "><span class="sc9">UNIT</span><span class="sc0"> </span><span class="sc1">utilidades</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">INTERFACE</span><span class="sc0">

    </span><span class="sc9">USES</span><span class="sc0">  
        </span><span class="sc1">strings</span><span class="sc13">,</span><span class="sc0"> </span><span class="sc1">baseunix</span><span class="sc13">,</span><span class="sc0"> </span><span class="sc1">sysutils</span><span class="sc13">,</span><span class="sc0"> </span><span class="sc1">dateutils</span><span class="sc13">;</span><span class="sc0">

    </span><span class="sc9">Const</span><span class="sc0">   
        </span><span class="sc1">N</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc7">300</span><span class="sc13">;</span><span class="sc0">            </span><span class="sc4">// Número máximo de archivos a listar en un directorio (ls)
</span><span class="sc0">        </span><span class="sc1">P</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc7">3</span><span class="sc13">;</span><span class="sc0">              </span><span class="sc4">// Número máximo de parámetros para los comandos (sin contar directorios)
</span><span class="sc0">        </span><span class="sc1">LF</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc12">#10</span><span class="sc13">;</span><span class="sc0">           </span><span class="sc4">// Caracter Line Feed.
</span><span class="sc0">        </span><span class="sc1">CR</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc12">#13</span><span class="sc13">;</span><span class="sc0">           </span><span class="sc4">// Caracter Carriage Return.
</span><span class="sc0">        </span><span class="sc1">CRLF</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">CR</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc1">LF</span><span class="sc13">;</span><span class="sc0">     </span><span class="sc4">// CRLF
</span><span class="sc0">    
    </span><span class="sc9">Type</span><span class="sc0"> 
        </span><span class="sc1">vDirent</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc9">array</span><span class="sc0"> </span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">..</span><span class="sc1">N</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc9">of</span><span class="sc0"> </span><span class="sc1">Dirent</span><span class="sc13">;</span><span class="sc0">           </span><span class="sc4">// Vector para almacenar nombres de archivos de un directorio y así ordenarlos.
</span><span class="sc0">        </span><span class="sc1">parametros</span><span class="sc13">=</span><span class="sc0"> </span><span class="sc9">array</span><span class="sc0"> </span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">..</span><span class="sc1">P</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc9">of</span><span class="sc0"> </span><span class="sc1">AnsiString</span><span class="sc13">;</span><span class="sc0">     </span><span class="sc4">// Vector para almacenar parámetros de comandos.
</span><span class="sc0">        
    </span><span class="sc9">var</span><span class="sc0"> 
        </span><span class="sc1">stdOutPut</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Text</span><span class="sc13">;</span><span class="sc0">            </span><span class="sc4">// Archivo de redirección de la salida estándar.
</span><span class="sc0">        </span><span class="sc1">strOutPut</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">          </span><span class="sc4">// Nombre del archivo de redirección.
</span><span class="sc0">        </span><span class="sc1">newInPut</span><span class="sc0"> </span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Text</span><span class="sc13">;</span><span class="sc0">            </span><span class="sc4">// Redirección de la entrada estándar para comando pipe.
</span><span class="sc0">        </span><span class="sc1">flagInPut</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Boolean</span><span class="sc13">;</span><span class="sc0">         </span><span class="sc4">// Se le asigna momentaneamente true durante un pipe.
</span><span class="sc0">        

</span><span class="sc4">//  UTILIDADES
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">puntos</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">                                    </span><span class="sc4">// Cantidad de puntos '.' en un string.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">dirActual</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                                             </span><span class="sc4">// Devuelve la dirección de trabajo actual.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">dirHome</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                                               </span><span class="sc4">// Devuelve el directorio Home. Por defecto /home/user.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">strSin</span><span class="sc13">(</span><span class="sc1">param1</span><span class="sc13">,</span><span class="sc0"> </span><span class="sc1">param2</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                        </span><span class="sc4">// elimina param2 de la cadena param1.
</span><span class="sc9">procedure</span><span class="sc0"> </span><span class="sc1">burbujaDirent</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">v</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">vDirent</span><span class="sc13">;</span><span class="sc0"> </span><span class="sc1">max</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">// ordena los archivos listados por ls. Algoritmo burbuja.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">redireccion</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                               </span><span class="sc4">// Devuelve true si encuentra los operadores '&gt;' o '&gt;&gt;' en la cadena.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tuberia</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                                   </span><span class="sc4">// Devuelve true si encuentra el operador '|' en una cadena.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">enBg</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                                      </span><span class="sc4">// Devuelve true si el proceso debe ejecutarse en background.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">solicitudBG</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                            </span><span class="sc4">// Verifica si se ingreso "bg", la solicitud para ejecutar un trabajo en segundo plano.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">solicitudFG</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                            </span><span class="sc4">// Verifica si se ingreso "fg", la solicitud para ejecutar un trabajo en primer plano.  
</span><span class="sc9">procedure</span><span class="sc0"> </span><span class="sc1">Mostrarerror</span><span class="sc13">(</span><span class="sc1">n</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">);</span><span class="sc0">                                     </span><span class="sc4">// Devuelve el mensaje de error &lt;n&gt;.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">V</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                                      </span><span class="sc4">// Convierte un valor a string.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tiempoUnixAHumano</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">tUnix</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                        </span><span class="sc4">// Convierte el valor de tiempo que devuelve Unix.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">permisosACadena</span><span class="sc13">(</span><span class="sc1">path</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                           </span><span class="sc4">// Verifica si el usuario tiene permisos de lectura, escritura y ejecución, y lo imprime.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tamAsString</span><span class="sc13">(</span><span class="sc1">tam</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">;</span><span class="sc0"> </span><span class="sc1">espacios</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">byte</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                 </span><span class="sc4">// Permite alinear un string.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">extraerComando</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                           </span><span class="sc4">// Devuelve el comando de la cadena (o primer componente antes del primer espacio), y se elimina el componente de la entrada recibida.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">extraerArgumentos</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">i</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc1">parametros</span><span class="sc13">;</span><span class="sc0">      </span><span class="sc4">// Devuelve un vector de argumentos de la forma -* y se eliminan los argumentos de la entrada recibida.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">modoACadena</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                              </span><span class="sc4">// Traduce los permisos de un archivo
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tipoArchivoAF</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                            </span><span class="sc4">// Traduce los tipos de archivos para el comando LS con parámetros A y/o F
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tipoArchivoL</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                             </span><span class="sc4">// Traduce los tipos de archivos para el comando LS con parámetro L
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">nombreComandoDesdeRuta</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                       </span><span class="sc4">// Dada una dirección absoluta a un comando, devuelve sólo el nombre del mismo.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">paramValido</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">                               </span><span class="sc4">// Determina si un parámetro del ls es válido o no.
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">stringToAnsiString</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">ansiString</span><span class="sc13">;</span><span class="sc0">                     </span><span class="sc4">// Convierte un string en un ansiString
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">ansiStringToString</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">ansiString</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                    </span><span class="sc4">// Convierte un ansiString en un string
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">sinEspacios</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">                                  </span><span class="sc4">// Elimina los espacios existentes en una cadena
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">eliminarSubcadena</span><span class="sc13">(</span><span class="sc1">cadena</span><span class="sc13">,</span><span class="sc1">subcadena</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">             </span><span class="sc4">// Elimina una subcadena de la cadena original
</span><span class="sc0">    
</span><span class="sc9">IMPLEMENTATION</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">eliminarSubcadena</span><span class="sc13">(</span><span class="sc1">cadena</span><span class="sc13">,</span><span class="sc1">subcadena</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">auxStr</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">posi</span><span class="sc13">:</span><span class="sc1">longint</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">auxStr</span><span class="sc13">:=</span><span class="sc1">cadena</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">posi</span><span class="sc13">:=</span><span class="sc7">0</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">posi</span><span class="sc13">:=</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">subcadena</span><span class="sc13">),</span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">cadena</span><span class="sc13">));</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">posi</span><span class="sc13">&lt;&gt;</span><span class="sc7">0</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">auxStr</span><span class="sc13">,</span><span class="sc1">posi</span><span class="sc13">,</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">subcadena</span><span class="sc13">));</span><span class="sc0">
    </span><span class="sc1">eliminarSubcadena</span><span class="sc13">:=</span><span class="sc1">auxstr</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">sinEspacios</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">strAux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">:</span><span class="sc1">longint</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">straux</span><span class="sc13">:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">:=</span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc9">begin</span><span class="sc0">
        </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">I</span><span class="sc13">]&lt;&gt;</span><span class="sc12">#32</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
            </span><span class="sc1">strAux</span><span class="sc13">:=</span><span class="sc1">strAux</span><span class="sc13">+</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">I</span><span class="sc13">];</span><span class="sc0">
        </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">sinEspacios</span><span class="sc13">:=</span><span class="sc1">strAux</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">V</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">S</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">STR</span><span class="sc13">(</span><span class="sc1">V</span><span class="sc13">,</span><span class="sc1">S</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc1">asString</span><span class="sc13">:=</span><span class="sc1">S</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

        
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">puntos</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">puntos</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc7">0</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">I</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc12">#46</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">puntos</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">puntos</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc7">1</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">dirActual</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">getDir</span><span class="sc13">(</span><span class="sc7">0</span><span class="sc13">,</span><span class="sc1">dirActual</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">
    
    
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">dirHome</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">dirHome</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">fpGetEnv</span><span class="sc13">(</span><span class="sc10">'HOME'</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">strSin</span><span class="sc13">(</span><span class="sc1">param1</span><span class="sc13">,</span><span class="sc0"> </span><span class="sc1">param2</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">strSin</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">rightStr</span><span class="sc13">(</span><span class="sc1">param1</span><span class="sc13">,((</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">param1</span><span class="sc13">))-(</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">param2</span><span class="sc13">))));</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">procedure</span><span class="sc0"> </span><span class="sc1">burbujaDirent</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">v</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">vDirent</span><span class="sc13">;</span><span class="sc0"> </span><span class="sc1">max</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">,</span><span class="sc1">J</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">aux</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Dirent</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">I</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">max</span><span class="sc13">-</span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
     </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">J</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">max</span><span class="sc13">-</span><span class="sc1">I</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
      </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">strPas</span><span class="sc13">(</span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">].</span><span class="sc1">d_name</span><span class="sc13">))</span><span class="sc0"> </span><span class="sc13">&gt;</span><span class="sc0"> </span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">strPas</span><span class="sc13">(</span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">+</span><span class="sc7">1</span><span class="sc13">].</span><span class="sc1">d_name</span><span class="sc13">))</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc9">Begin</span><span class="sc0">
            </span><span class="sc1">aux</span><span class="sc0"> </span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">+</span><span class="sc7">1</span><span class="sc13">];</span><span class="sc0">
            </span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">+</span><span class="sc7">1</span><span class="sc13">]:=</span><span class="sc0"> </span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">];</span><span class="sc0">
            </span><span class="sc1">v</span><span class="sc13">[</span><span class="sc1">J</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">aux</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">
    
    
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">redireccion</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">redireccion</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">' &gt; '</span><span class="sc13">,</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc7">0</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">' &gt;&gt; '</span><span class="sc13">,</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc7">0</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tuberia</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">tuberia</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">' | '</span><span class="sc13">,</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc7">0</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">enBg</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc0"> </span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">enBg</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc13">((</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc7">1</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">' &amp;'</span><span class="sc13">,</span><span class="sc1">s</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">)-</span><span class="sc7">1</span><span class="sc13">));</span><span class="sc0"> </span><span class="sc4">// Debe ser lo ultimo escrito 
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">    
    
    
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">solicitudBG</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc1">solicitudBG</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'BG'</span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">solicitudFG</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">solicitudFG</span><span class="sc13">:=</span><span class="sc10">'FG'</span><span class="sc13">=</span><span class="sc1">upcase</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
    
    
</span><span class="sc9">procedure</span><span class="sc0"> </span><span class="sc1">Mostrarerror</span><span class="sc13">(</span><span class="sc1">n</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">integer</span><span class="sc13">);</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0">
    </span><span class="sc1">errorAux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">Begin</span><span class="sc0">
    </span><span class="sc9">case</span><span class="sc0"> </span><span class="sc1">n</span><span class="sc0"> </span><span class="sc9">of</span><span class="sc0">
    </span><span class="sc7">1</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 1: Parámetros insuficientes.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">2</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 2: No se puede reconocer el comando.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">3</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 3: Falla en el Fork, no es posible ejecutar el nuevo proceso.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">4</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 4: El directorio no existe, o no puede ser accedido.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">5</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 5: Comando no reconocido.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">6</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 6: Error en Exec, no es posible ejecutar el proceso.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">7</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 7: El programa no se encuentra en el Path.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">8</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 8: Parámetros incorrectos.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">9</span><span class="sc13">:</span><span class="sc0">      </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 9: Los parámetros deben ser de tipo numérico.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">10</span><span class="sc13">:</span><span class="sc0">     </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 10: Error al intentar abrir el/los archivo(s).'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">11</span><span class="sc13">:</span><span class="sc0">     </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 11: Error de redirección de la salida estándar - Operador ''&gt;'''</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">12</span><span class="sc13">:</span><span class="sc0">     </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 12: Error de redirección de la salida estándar - Operador ''&gt;&gt;'''</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">13</span><span class="sc13">:</span><span class="sc0">     </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 13: Error al intentar crear tuberías.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc7">20</span><span class="sc13">:</span><span class="sc0">     </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error nº 20: Trabajo no encontrado.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">else</span><span class="sc0">    </span><span class="sc1">errorAux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">'Error desconocido.'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">writeln</span><span class="sc13">(</span><span class="sc1">errorAux</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">n</span><span class="sc0"> </span><span class="sc9">in</span><span class="sc0"> </span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">2</span><span class="sc13">,</span><span class="sc7">5</span><span class="sc13">,</span><span class="sc7">8</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">writeln</span><span class="sc13">(</span><span class="sc10">'Si necesita ayuda utilice el comando "help".'</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc9">exit</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">End</span><span class="sc13">;</span><span class="sc0">
    
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">numAMes</span><span class="sc13">(</span><span class="sc1">numMes</span><span class="sc13">:</span><span class="sc1">word</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> 
    </span><span class="sc1">Aux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc9">case</span><span class="sc0"> </span><span class="sc1">numMes</span><span class="sc0"> </span><span class="sc9">of</span><span class="sc0">
        </span><span class="sc7">1</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'ene'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">2</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'feb'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">3</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'mar'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">4</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'abr'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">5</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'may'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">6</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'jun'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">7</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'jul'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">8</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'ago'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">9</span><span class="sc13">:</span><span class="sc0">  </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'sep'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">10</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'oct'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">11</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'nov'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc7">12</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'dic'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc1">numAMes</span><span class="sc13">:=</span><span class="sc1">aux</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
    
</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tiempoUnixAHumano</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">tUnix</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> 
    </span><span class="sc1">Y</span><span class="sc13">,</span><span class="sc1">Mo</span><span class="sc13">,</span><span class="sc1">D</span><span class="sc13">,</span><span class="sc1">H</span><span class="sc13">,</span><span class="sc1">Mi</span><span class="sc13">,</span><span class="sc1">S</span><span class="sc13">,</span><span class="sc1">MS</span><span class="sc0"> </span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">Word</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">Aux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">DecodeDateTime</span><span class="sc13">(</span><span class="sc1">UnixToDateTime</span><span class="sc13">(</span><span class="sc1">tUnix</span><span class="sc13">),</span><span class="sc1">Y</span><span class="sc13">,</span><span class="sc1">Mo</span><span class="sc13">,</span><span class="sc1">D</span><span class="sc13">,</span><span class="sc1">H</span><span class="sc13">,</span><span class="sc1">Mi</span><span class="sc13">,</span><span class="sc1">S</span><span class="sc13">,</span><span class="sc1">MS</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">numAMes</span><span class="sc13">(</span><span class="sc1">Mo</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">D</span><span class="sc13">&lt;</span><span class="sc7">10</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">D</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc0">
    </span><span class="sc9">else</span><span class="sc0">
        </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">D</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">Y</span><span class="sc13">&lt;</span><span class="sc7">2014</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">Y</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc0">
    </span><span class="sc9">else</span><span class="sc0">
        </span><span class="sc9">begin</span><span class="sc0">
        </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">H</span><span class="sc13">&lt;</span><span class="sc7">10</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
            </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc10">'0'</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">H</span><span class="sc13">)+</span><span class="sc10">':'</span><span class="sc0">
        </span><span class="sc9">else</span><span class="sc0">
            </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">H</span><span class="sc13">)+</span><span class="sc10">':'</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">Mi</span><span class="sc13">&lt;</span><span class="sc7">10</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
            </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc10">'0'</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">Mi</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc0">
        </span><span class="sc9">else</span><span class="sc0">
            </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">Mi</span><span class="sc13">)+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">tiempoUnixAHumano</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">permisosACadena</span><span class="sc13">(</span><span class="sc1">path</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0">
    </span><span class="sc1">Aux</span><span class="sc13">:</span><span class="sc9">String</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'---'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpAccess</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">path</span><span class="sc13">,</span><span class="sc1">R_OK</span><span class="sc13">)=</span><span class="sc7">0</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]:=</span><span class="sc10">'r'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpAccess</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">path</span><span class="sc13">,</span><span class="sc1">W_OK</span><span class="sc13">)=</span><span class="sc7">0</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">2</span><span class="sc13">]:=</span><span class="sc10">'w'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpAccess</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">path</span><span class="sc13">,</span><span class="sc1">X_OK</span><span class="sc13">)=</span><span class="sc7">0</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">3</span><span class="sc13">]:=</span><span class="sc10">'x'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">permisosACadena</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tamAsString</span><span class="sc13">(</span><span class="sc1">tam</span><span class="sc13">:</span><span class="sc1">int64</span><span class="sc13">;</span><span class="sc0"> </span><span class="sc1">espacios</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">byte</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0">
    </span><span class="sc1">aux</span><span class="sc13">,</span><span class="sc1">buff</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">i</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">buff</span><span class="sc13">:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc1">asString</span><span class="sc13">(</span><span class="sc1">tam</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">i</span><span class="sc13">:=</span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">espacios</span><span class="sc13">-</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">aux</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc1">buff</span><span class="sc13">:=</span><span class="sc1">buff</span><span class="sc13">+</span><span class="sc10">' '</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">tamAsString</span><span class="sc13">:=</span><span class="sc1">buff</span><span class="sc13">+</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">extraerComando</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">aux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc1">e</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]=</span><span class="sc10">' '</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">//eliminar espacios iniciales
</span><span class="sc0">    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
    </span><span class="sc9">begin</span><span class="sc0">
        </span><span class="sc1">e</span><span class="sc13">:=</span><span class="sc7">1</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">repeat</span><span class="sc0">                          </span><span class="sc4">//comienza detección de primer componente
</span><span class="sc0">        </span><span class="sc9">begin</span><span class="sc0">
            </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc1">aux</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">];</span><span class="sc0">                    </span><span class="sc4">//agrega un caracter
</span><span class="sc0">            </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc10">'"'</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">                  </span><span class="sc4">//si el ultimo elemento agregado es ".
</span><span class="sc0">            </span><span class="sc9">begin</span><span class="sc0">       
                </span><span class="sc1">inc</span><span class="sc13">(</span><span class="sc1">e</span><span class="sc13">);</span><span class="sc0">
                </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc10">'"'</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">            </span><span class="sc4">//agrega todo hasta el proximo ".
</span><span class="sc0">                </span><span class="sc9">begin</span><span class="sc0">
                    </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc1">aux</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">];</span><span class="sc0">
                    </span><span class="sc1">inc</span><span class="sc13">(</span><span class="sc1">e</span><span class="sc13">);</span><span class="sc0">
                </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
                </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc1">aux</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">];</span><span class="sc0">                </span><span class="sc4">//agrega las " de cierre
</span><span class="sc0">            </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
            </span><span class="sc1">inc</span><span class="sc13">(</span><span class="sc1">e</span><span class="sc13">);</span><span class="sc0">
        </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">until</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">e</span><span class="sc13">&gt;</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">))</span><span class="sc9">OR</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc1">e</span><span class="sc13">]</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc10">' '</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">//se encontró un espacio fuera de ""
</span><span class="sc0">        </span><span class="sc1">extraerComando</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">aux</span><span class="sc13">;</span><span class="sc0">               </span><span class="sc4">//devolver comando
</span><span class="sc0">        </span><span class="sc1">s</span><span class="sc13">:=</span><span class="sc1">copy</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">aux</span><span class="sc13">)+</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">));</span><span class="sc0"> </span><span class="sc4">//la entrada se recorta hasta el primer parametro
</span><span class="sc0">        </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]=</span><span class="sc10">' '</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
            </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">//eliminar espacios iniciales
</span><span class="sc0">    </span><span class="sc9">end</span><span class="sc0">
    </span><span class="sc9">else</span><span class="sc0">
        </span><span class="sc1">extraerComando</span><span class="sc13">:=</span><span class="sc1">s</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">extraerArgumentos</span><span class="sc13">(</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">i</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc1">parametros</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">j</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">;</span><span class="sc1">param</span><span class="sc13">:</span><span class="sc1">ansiString</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc9">for</span><span class="sc0"> </span><span class="sc1">j</span><span class="sc13">:=</span><span class="sc7">1</span><span class="sc0"> </span><span class="sc9">to</span><span class="sc0"> </span><span class="sc1">P</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc1">extraerArgumentos</span><span class="sc13">[</span><span class="sc1">j</span><span class="sc13">]:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">       </span><span class="sc4">//inicializar vector de argumentos
</span><span class="sc0">    </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc9">AND</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]=</span><span class="sc10">' '</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">//eliminar espacios iniciales
</span><span class="sc0">    </span><span class="sc1">i</span><span class="sc13">:=</span><span class="sc7">0</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">param</span><span class="sc13">:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">i</span><span class="sc13">&lt;=</span><span class="sc1">N</span><span class="sc13">)</span><span class="sc9">AND</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc9">AND</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]=</span><span class="sc10">'-'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">DO</span><span class="sc0">      </span><span class="sc4">//comienza detección de primer componente
</span><span class="sc0">    </span><span class="sc9">begin</span><span class="sc0">
        </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">      </span><span class="sc4">//elimina el guion que indica parametro
</span><span class="sc0">        </span><span class="sc9">WHILE</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc9">AND</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]&lt;&gt;</span><span class="sc10">' '</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">DO</span><span class="sc0">
        </span><span class="sc9">begin</span><span class="sc0">
            </span><span class="sc1">param</span><span class="sc13">:=</span><span class="sc1">param</span><span class="sc0"> </span><span class="sc13">+</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">];</span><span class="sc0">
            </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">
        </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc1">inc</span><span class="sc13">(</span><span class="sc1">i</span><span class="sc13">);</span><span class="sc0">
        </span><span class="sc1">extraerArgumentos</span><span class="sc13">[</span><span class="sc1">i</span><span class="sc13">]:=</span><span class="sc1">param</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc1">param</span><span class="sc13">:=</span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">
        </span><span class="sc9">WHILE</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">&lt;&gt;</span><span class="sc10">''</span><span class="sc13">)</span><span class="sc9">AND</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]=</span><span class="sc10">' '</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">DO</span><span class="sc0">
            </span><span class="sc1">delete</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc7">1</span><span class="sc13">);</span><span class="sc0">                  </span><span class="sc4">//eliminar espacios entre parametros
</span><span class="sc0">    </span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">modoACadena</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> 
    </span><span class="sc1">Aux</span><span class="sc13">:</span><span class="sc9">String</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">Aux</span><span class="sc13">:=</span><span class="sc10">'----------'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IFDIR</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IFDIR</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">1</span><span class="sc13">]:=</span><span class="sc10">'d'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IRUSR</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IRUSR</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">2</span><span class="sc13">]:=</span><span class="sc10">'r'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IWUSR</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IWUSR</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">3</span><span class="sc13">]:=</span><span class="sc10">'w'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IXUSR</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IXUSR</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">4</span><span class="sc13">]:=</span><span class="sc10">'x'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IRGRP</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IRGRP</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">5</span><span class="sc13">]:=</span><span class="sc10">'r'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IWGRP</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IWGRP</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">6</span><span class="sc13">]:=</span><span class="sc10">'w'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IXGRP</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IXGRP</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">7</span><span class="sc13">]:=</span><span class="sc10">'x'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IROTH</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IROTH</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">8</span><span class="sc13">]:=</span><span class="sc10">'r'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IWOTH</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IWOTH</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">9</span><span class="sc13">]:=</span><span class="sc10">'w'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc0"> </span><span class="sc9">and</span><span class="sc0"> </span><span class="sc1">S_IXOTH</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">=</span><span class="sc0"> </span><span class="sc1">S_IXOTH</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> </span><span class="sc1">Aux</span><span class="sc13">[</span><span class="sc7">10</span><span class="sc13">]:=</span><span class="sc10">'x'</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc1">modoACadena</span><span class="sc13">:=</span><span class="sc1">Aux</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tipoArchivoAF</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISLNK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(L)'</span><span class="sc13">)</span><span class="sc0">
        </span><span class="sc9">else</span><span class="sc0">
            </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISCHR</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> 
                </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(C)'</span><span class="sc13">)</span><span class="sc0">
            </span><span class="sc9">else</span><span class="sc0">
                </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISREG</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                    </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(F)'</span><span class="sc13">)</span><span class="sc0">
                </span><span class="sc9">else</span><span class="sc0">
                    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISDIR</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                        </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(D)'</span><span class="sc13">)</span><span class="sc0">
                        </span><span class="sc9">else</span><span class="sc0">
                            </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISBLK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                                </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(B)'</span><span class="sc13">)</span><span class="sc0">
                            </span><span class="sc9">else</span><span class="sc0">
                                </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISFIFO</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                                    </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(I)'</span><span class="sc13">)</span><span class="sc0">
                                </span><span class="sc9">else</span><span class="sc0">
                                    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISSOCK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                                        </span><span class="sc1">tipoArchivoAF</span><span class="sc13">:=(</span><span class="sc10">'(S)'</span><span class="sc13">);</span><span class="sc0">     
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">


</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">tipoArchivoL</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">:</span><span class="sc1">integer</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISLNK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
        </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'LNK'</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">)</span><span class="sc0">
        </span><span class="sc9">else</span><span class="sc0">
            </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISCHR</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0"> 
                </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'CHR'</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">)</span><span class="sc0">
            </span><span class="sc9">else</span><span class="sc0">
                </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISREG</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                    </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'FILE'</span><span class="sc13">)</span><span class="sc0">
                </span><span class="sc9">else</span><span class="sc0">
                    </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISDIR</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                        </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'DIR'</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">)</span><span class="sc0">
                    </span><span class="sc9">else</span><span class="sc0">
                        </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISBLK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                            </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'BLK'</span><span class="sc13">+</span><span class="sc12">#32</span><span class="sc13">)</span><span class="sc0">
                        </span><span class="sc9">else</span><span class="sc0">
                            </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISFIFO</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                                </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'FIFO'</span><span class="sc13">)</span><span class="sc0">
                            </span><span class="sc9">else</span><span class="sc0">
                                </span><span class="sc9">if</span><span class="sc0"> </span><span class="sc1">fpS_ISSOCK</span><span class="sc13">(</span><span class="sc1">modo</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">then</span><span class="sc0">
                                    </span><span class="sc1">tipoArchivoL</span><span class="sc13">:=(</span><span class="sc10">'SOCK'</span><span class="sc13">);</span><span class="sc0">     
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">nombreComandoDesdeRuta</span><span class="sc13">(</span><span class="sc1">s</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">var</span><span class="sc0"> </span><span class="sc1">aux</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">s</span><span class="sc13">;</span><span class="sc0">
    </span><span class="sc9">while</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">'/'</span><span class="sc13">,</span><span class="sc1">aux</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc13">&lt;&gt;</span><span class="sc0"> </span><span class="sc7">0</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">do</span><span class="sc0">
        </span><span class="sc1">aux</span><span class="sc13">:=</span><span class="sc1">copy</span><span class="sc13">(</span><span class="sc1">aux</span><span class="sc13">,</span><span class="sc1">pos</span><span class="sc13">(</span><span class="sc10">'/'</span><span class="sc13">,</span><span class="sc1">aux</span><span class="sc13">)+</span><span class="sc7">1</span><span class="sc13">,</span><span class="sc1">length</span><span class="sc13">(</span><span class="sc1">aux</span><span class="sc13">));</span><span class="sc0">
    </span><span class="sc1">nombreComandoDesdeRuta</span><span class="sc13">:=</span><span class="sc1">aux</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">paramValido</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">boolean</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">str</span><span class="sc13">:=</span><span class="sc1">UPCASE</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">);</span><span class="sc0">
    </span><span class="sc1">paramValido</span><span class="sc13">:=(</span><span class="sc0">
                    </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'A'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'F'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'L'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0">
                    </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'LA'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'LF'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'AL'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'AF'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'FL'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'FA'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0">
                    </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'LFA'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'LAF'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'FLA'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'FAL'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'AFL'</span><span class="sc13">)</span><span class="sc0"> </span><span class="sc9">or</span><span class="sc0"> </span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">=</span><span class="sc10">'ALF'</span><span class="sc13">)</span><span class="sc0">
                </span><span class="sc13">)</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">stringToAnsiString</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc9">string</span><span class="sc13">):</span><span class="sc1">ansiString</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">stringToAnsiString</span><span class="sc13">:=</span><span class="sc1">str</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">function</span><span class="sc0"> </span><span class="sc1">ansiStringToString</span><span class="sc13">(</span><span class="sc1">str</span><span class="sc13">:</span><span class="sc0"> </span><span class="sc1">ansiString</span><span class="sc13">):</span><span class="sc9">string</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">begin</span><span class="sc0">
    </span><span class="sc1">ansiStringToString</span><span class="sc13">:=</span><span class="sc1">str</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">end</span><span class="sc13">;</span><span class="sc0">

</span><span class="sc9">BEGIN</span><span class="sc0">
    </span><span class="sc2">{ 
        No utilizado, se guarda por compatibilidad con OShell
    }</span><span class="sc0">
    </span><span class="sc1">strOutPut</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc10">''</span><span class="sc13">;</span><span class="sc0">                 </span><span class="sc4">// StrOutPut refiere a la redirección de la salida estándar.
</span><span class="sc0">    </span><span class="sc1">setTextLineEnding</span><span class="sc13">(</span><span class="sc1">stdOut</span><span class="sc13">,</span><span class="sc1">CRLF</span><span class="sc13">);</span><span class="sc0"> </span><span class="sc4">// Asignándole formato a la salida estándar.
</span><span class="sc0">    </span><span class="sc1">flagInPut</span><span class="sc13">:=</span><span class="sc0"> </span><span class="sc1">false</span><span class="sc13">;</span><span class="sc0">
</span><span class="sc9">END</span><span class="sc13">.</span><span class="sc0">
</span></div></body>
</html>
